<html>
<head><meta charset="utf-8"><title>diagnostics for crate version mismatch · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.20for.20crate.20version.20mismatch.html">diagnostics for crate version mismatch</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="180554377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%20for%20crate%20version%20mismatch/near/180554377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Timo Freiberg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.20for.20crate.20version.20mismatch.html#180554377">(Nov 12 2019 at 19:53)</a>:</h4>
<p>Hi everyone, I'm trying to work on <a href="https://github.com/rust-lang/rust/issues/22750" target="_blank" title="https://github.com/rust-lang/rust/issues/22750">https://github.com/rust-lang/rust/issues/22750</a>, trying to add a help message to the <code>the trait X is not implemented for MyStruct</code> message if <code>MyStruct</code> implements a trait <code>X</code> from a different crate version.<br>
I actually got that message working <a href="https://github.com/rust-lang/rust/compare/master...TimoFreiberg:trait-name-report?expand=1" target="_blank" title="https://github.com/rust-lang/rust/compare/master...TimoFreiberg:trait-name-report?expand=1">here</a>, but I would very much like to show the expected and actual crate versions. I have no idea if that's even possible in rustc, I didn't find anything outside of rustdoc. Any suggestions?</p>



<a name="180572989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%20for%20crate%20version%20mismatch/near/180572989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.20for.20crate.20version.20mismatch.html#180572989">(Nov 12 2019 at 23:23)</a>:</h4>
<p>It seems to me that you _could_ use <code>self.tcx.crate_hash()</code>, but the result of that is not something that a user would necessarily be able to relate to anything. Making the error include the crate version would entail 1) adding an optional flag to <code>rustc</code> to accept a crate version string and 2) make <code>cargo</code> pass that flag in when compiling a crate.</p>



<a name="180639374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%20for%20crate%20version%20mismatch/near/180639374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Timo Freiberg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.20for.20crate.20version.20mismatch.html#180639374">(Nov 13 2019 at 15:46)</a>:</h4>
<p>Thanks again for the response! Okay, I think I'll probably first try to add some helpful diagnostics without including the crate version.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>